var minCostClimbingStairs = function(cost) {
  if(cost.length === 0){
    return 0
  }
  if(cost.length <=2){
    return Math.min(cost[0],cost[1])
  }
  for(let i = 2; i <cost.length;i++){
    cost[i] += Math.min(cost[i-1] ,cost[i-2])
  }
  return Math.min(cost[cost.length-1],cost[cost.length-2])
};
console.log(minCostClimbingStairs( [10,15,1]));